import request from "@/axios/axios"

// 获取固件列表
export function getFirmwareList(params) {
  return request({
    url: "/ota/v1/firmware/info/get-firmware-list",
    method: "post",
    data: params
  })
}

// 获取固件详情
export function getFirmwareInfo(data) {
  return request({
    url: "/ota/v1/firmware/info/get-firmware-info",
    method: "get",
    params: data
  })
}

// 编辑固件信息
export function updateFirmwareInfo(params) {
  return request({
    url: "/ota/v1/firmware/info/update-firmware-info",
    method: "post",
    data: params
  })
}

// 固件文件上传
export function uploadFile(params) {
  return request({
    url: "/ota/v1/firmware/info/file/upload",
    method: "post",
    data: params
  })
}

// 添加固件
export function addFirmware(params) {
  return request({
    url: "/ota/v1/firmware/info/add-firmware-info",
    method: "post",
    data: params
  })
}

// 功能定义列表
export function propertiesList(query) {
  return request({
    url: "device/v1/product/tsl",
    method: "post",
    data: query
  })
}

// 添加物模型数据
export function addProperties(query) {
  return request({
    url: "device/v1/product/update/tsl",
    method: "post",
    data: query
  })
}

// 删除物模型数据
export function detele(query) {
  return request({
    url: "device/v1/product/delete/tsl",
    method: "post",
    data: query
  })
}

// 获取删除掉的产品物模型
export function getDeletedProperties(query) {
  return request({
    url: "device/v1/product/tsl/deleted",
    method: "post",
    data: query
  })
}

// 获取事件-动作下面的物模型属性
export function getProperties(query) {
  return request({
    url: "device/v1/product/properties",
    method: "post",
    data: query
  })
}

// 获取高级功能列表数据
export function advancedFunc(productId) {
  return request({
    url: `device/v1/product/advanced/functions/${productId}`,
    method: "GET"
  })
}
// 更新产品高级功能
export function updateAdvancedFunc(query) {
  return request({
    url: "device/v1/product/update/advanced/functions",
    method: "post",
    data: query
  })
}

// 发布产品
export function publishProduct(productId) {
  return request({
    url: `device/v1/product/publish/${productId}`,
    method: "GET"
  })
}

// 修改产品状态(返回开发)
export function productStatus(query) {
  return request({
    url: 'device/v1/product/change/status',
    method: "put",
    data: query
  })
}

// 查询产品
export function queryProduct(query) {
  return request({
    url: "device/v1/product/query",
    method: "post",
    data: query
  })
}

// 修改产品信息
export function updateProduct(query) {
  return request({
    url: "device/v1/product/update",
    method: "post",
    data: query
  })
}

// 通过产品id查询产品组网配置
export function getNetConfig(data) {
  return request({
    url: "device/v1/product/network/config/guide",
    method: "get",
    params: data
  })
}

// 新增产品组网配置
export function addNetConfig(query) {
  return request({
    url: "device/v1/product/network/config",
    method: "post",
    data: query
  })
}

// 查询测试报告
export function getReport(productId) {
  return request({
    url: `device/v1/product/report/by/${productId}`,
    method: "get"
  })
}

// 新增/修改产品报告
export function addReport(query) {
  return request({
    url: "device/v1/product/report",
    method: "post",
    data: query
  })
}

// 下载文件
export function download(fileName) {
  return request({
    url: `device/sys/file/${fileName}`,
    method: "get"
  })
}

//删除固件
export function deleteFirmwareInfo(data) {
  return request({
    url: "ota/v1/firmware/info/delete-firmware-info",
    method: "get",
    params: data
  })
}

// 更改固件发布与取消发布
export function updateFirmwareReleaseStatus(query) {
  return request({
    url: "/ota/v1/firmware/info/update-firmware-release-status",
    method: "post",
    data: query
  })
}

// 获取测试任务详情
export function getTestTaskList(query) {
  return request({
    url: "ota/v1/firmware/task/get-test-task-list",
    method: "post",
    data: query
  })
}

// 新增产品场景配置
export function addSceneConfig(query) {
  return request({
    url: "device/v1/product/scene/config",
    method: "post",
    data: query
  })
}

// 新建测试任务
export function addTestTask(query) {
  return request({
    url: "ota/v1/firmware/task/add-test-task",
    method: "post",
    data: query
  })
}

// 获取测试任务降级版本号
export function getDowngradeVersionList(query) {
  return request({
    url: "ota/v1/firmware/task/get-downgrade-version-list",
    method: "post",
    data: query
  })
}

// 通过产品Id查询
export function getSceneConfig(productId) {
  return request({
    url: `device/v1/product/scene/config/by/${productId}`,
    method: "get"
  })
}

// 获取测试任务任务类型
export function getTestTaskTypeList(data) {
  return request({
    url: "ota/v1/firmware/task/get-test-task-type-list",
    method: "get",
    params: data
  })
}

// 删除测试任务
export function deleteTestTask(data) {
  return request({
    url: "ota/v1/firmware/task/delete-test-task",
    method: "get",
    params: data
  })
}

// 终止测试任务
export function terminateTestTask(data) {
  return request({
    url: "ota/v1/firmware/task/terminate-test-task",
    method: "get",
    params: data
  })
}

// 获取测试任务详情
export function getTestTaskInfo(data) {
  return request({
    url: "ota/v1/firmware/task/get-test-task-info",
    method: "get",
    params: data
  })
}

// 固件上线
export function firmwareOnline(data) {
  return request({
    url: "ota/v1/firmware/info/firmware-online",
    method: "get",
    params: data
  })
}

// 获取升级任务可升级版本号
export function getUpgradeVersionList(query) {
  return request({
    url: "ota/v1/firmware/task/get-upgrade-version-list",
    method: "post",
    data: query
  })
}

// 获取升级任务列表
export function getUpgradeTaskList(query) {
  return request({
    url: "ota/v1/firmware/task/get-upgrade-task-list",
    method: "post",
    data: query
  })
}

// 新增升级任务
export function addUpgradeTask(query) {
  return request({
    url: "ota/v1/firmware/task/add-upgrade-task",
    method: "post",
    data: query
  })
}

// 终止升级任务
export function terminateUpgradeTask(data) {
  return request({
    url: "ota/v1/firmware/task/terminate-upgrade-task",
    method: "get",
    params: data
  })
}

// 获取升级任务详情
export function getUpgradeTaskInfo(data) {
  return request({
    url: "ota/v1/firmware/task/get-upgrade-task-info",
    method: "get",
    params: data
  })
}

// 删除升级任务
export function deleteUpgradeTask(data) {
  return request({
    url: "ota/v1/firmware/task/delete-upgrade-task",
    method: "get",
    params: data
  })
}

// 产品场景配置接口
export function propertiesEventBy(data) {
  return request({
    url: `device/v1/product/properties/and/events/by/${data}`,
    method: "get"
  })
}

// 获取产品物模型文本域
export function productTextArea(data) {
  return request({
    url: 'device/v1//product/query/product/text/area',
    method: "get",
    params: data
  })
}

// 保存产品物模型文本域
export function saveProductTextArea(query) {
  return request({
    url: "/device/v1/product/save/product/text/area",
    method: "post",
    data: query
  })
}

// 获取执行ota任务具体详情
export function getTaskExecutionRecord(query) {
  return request({
    url: "/ota/v1/firmware/task/get-task-execution-record-list",
    method: "post",
    data: query
  })
}
